import request from '@/utils/request'
import querystring from 'querystring'

export function getSellById(id) {
  return request.get('/sell/detail/' + id)
}

export function getSellFindById(id) {
  return request.get('/sell/findById/' + id)
}

export function addSell(param) {
  return request.post('/sell/save', param)
}

export function editSell(param) {
  return request.put('/sell/save', param)
}

export function deleteSell(id) {
  return request.delete('/sell/del/' + id)
}

export function sellList(param, pageSize, pageNo) {
  const data = {
    pageNo,
    pageSize,
    param: {
      ...param
    }
  }
  return request.post('/sell/page', data)
}
/**
 * 销售单精品分页
 * @param {*} param 
 * @param {*} pageSize 
 * @param {*} pageNo 
 */
export function sellJpPage(param, pageSize, pageNo) {
  const data = {
    pageNo,
    pageSize,
    param: {
      ...param
    }
  }
  return request.post('/sell/jpPage', data)
}

//生成工单编号
export function sellGetWorkOrderCode() {
  return request.get(`/sell/getWorkOrderCode`)
}
/**
 * 销售单配件分页查询
 * @param {*} param 
 * @param {*} pageSize 
 * @param {*} pageNo 
 */
export function sellPartsPage(param, pageSize, pageNo) {
  const data = {
    pageNo,
    pageSize,
    param: {
      ...param
    }
  }
  return request.post('/sell/partsPage', data)
}

/**
 * 销售单确认退料
 * @param {*} param 
 */
export function sellReturnMaterial(param) {
  return request.post('/sell/returnMaterial', param)
}

/**
 * 销售单确认精品退料
 * @param {*} param 
 */
 export function sellReturnJpMaterial(param) {
  return request.post('/sell/returnJpMaterial', param)
}


/**
 * 销售单确认精品换料
 * @param {*} param 
 */
 export function sellChangeJpMaterial(param) {
  return request.post('/sell/changeJpMaterial', param)
}


/**
 * 销售单确认配件换料
 * @param {*} param 
 */
 export function sellChangePartsMaterial(param) {
  return request.post('/sell/changePartsMaterial', param)
}
/**
 * 工单派工
 * @param {*} id 
 */
 export function getSellDispatch(id) {
  return request.get(`/sell/dispatch/${id}`)
}
